package com.CityHunter.OverLay;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Point;

import com.CityHunter.Track;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class TrackOverLay  extends Overlay{
	Track track;
	public TrackOverLay(Track track){
		this.track=track;
	}
	 public void draw(Canvas canvas, MapView mapView, boolean shadow) {
			
			Paint p = new Paint();
			Path myPath = new Path();
		     
		
			for(int i=0;i<track.length()-1;i++) {
				 Point out = new Point();
				mapView.getProjection().toPixels(track.getPoint(i), out);
				
				
				  if( i == 0 ){
                      myPath.moveTo(out.x, out.y);
				  System.out.print(track.length());}
                  else if( i+1 != track.length() )
                      myPath.lineTo(out.x, out.y);
                  else
                      myPath.setLastPoint(out.x, out.y);
			

			
				
			}
		

			p.setColor(Color.RED);
			   p.setStyle(Style.STROKE);
			   p.setStrokeWidth(10);
			   p.setAlpha(70);
		
			   canvas.drawPath(myPath, p); 
			   super.draw(canvas, mapView, shadow);
		 }
}
